<div class="ibox float-e-margins">
    <div class="ibox-content" style="display: block;">
        {!! Form::open( [ 'url' => [route('admin.activity.banner.store')], 'method' => 'POST','id' => 'base-form','class'=>'form-horizontal'] ) !!}
        <input type="hidden" name="id" value="{{$brand_list->id}}">
        <div class="form-group">
            {!! Form::label('name','banner图片：', ['class' => 'col-md-3 control-label']) !!}
            <div class="col-md-9">
                <input type="hidden" name="logo" value="{{$brand_list->banner_url}}"/>
                <img class="banner-image" src="{{$brand_list->banner_url}}">
                <div id="filePicker">选择图片</div>

            </div>
        </div>
        <div class="form-group">
            {!! Form::label('name','banner跳转链接：', ['class' => 'col-md-3 control-label']) !!}
            <div class="col-md-9">
                <input type="text" class="form-control" id="sort" name="link_url" placeholder="" value="{{$brand_list->link_url}}">
            </div>
        </div>

        <div class="form-group">
            {!! Form::label('name','排序：', ['class' => 'col-md-3 control-label']) !!}
            <div class="col-md-9">
                <input type="text" class="form-control" id="sort" name="sort" placeholder="" value="{{$brand_list->sort}}">
            </div>
        </div>

        <div class="form-group">
            {!! Form::label('name','是否显示：', ['class' => 'col-md-3 control-label']) !!}
            <div class="col-md-9">
                <div class="radio">
                    <label>
                        <input type="radio" name="is_valid" id="is_show" value="1"
                               @if($brand_list->is_valid==1) checked @endif>
                        是
                    </label>
                    <label>
                        <input type="radio" name="is_valid" id="is_show" value="2"
                               @if($brand_list->is_valid==2) checked @endif >
                        否
                    </label>
                </div>
            </div>
        </div>

        <div class="hr-line-dashed"></div>
        <div class="form-group">
            <div class="col-md-offset-2 col-md-8 controls">
                <button type="submit" class="btn btn-primary">保存</button>
            </div>
        </div>
    {!! Form::close() !!}
    <!-- /.tab-content -->
    </div>
</div>

{!! Html::script(env("APP_URL").'/vendor/libs/jquery.form.min.js') !!}
{!! Html::script(env("APP_URL").'/vendor/libs/webuploader-0.1.5/webuploader.js') !!}
<script>
    $('#base-form').ajaxForm({
        success: function (result) {
            $("input[name='id']").val(result.data);
            swal({
                title: "保存成功！",
                text: "",
                type: "success"
            }, function() {
                location = '{{route('admin.activity.banner.index')}}';
            });


        }
    });

    $(function () {
        var uploader = WebUploader.create({
            // 选完文件后，是否自动上传。
            auto: true,
            swf: '{{url(env("APP_URL").'/assets/backend/libs/webuploader-0.1.5/Uploader.swf')}}',
            server: '{{route('upload.image',['_token'=>csrf_token()])}}',
            pick: '#filePicker',
            fileVal: 'upload_image',
            accept: {
                title: 'Images',
                extensions: 'gif,jpg,jpeg,bmp,png',
                mimeTypes: 'image/*'
            }
        });
        // 文件上传成功，给item添加成功class, 用样式标记上传成功。
        uploader.on('uploadSuccess', function (file, response) {
            $('.banner-image').attr('src', response.url).show();
            $("input[name='banner_pic']").val(response.file);
            $("input[name='logo']").val(response.url);

        });
    })
</script>

